Added the legacy peer name detection algorithm. If the new algorithm
fails to find a peer's name (e.g. when the IP address has been changed)
then the legacy value will be used.
Signed-off-by: Tom Haley <[email protected]>
}
else {
let peer_name;
+ let peer_name_legacy;
uci.foreach('network', `wireguard_${last_device}`, (s) => {
if (!s.disabled && s.public_key == record[1] && (!s.endpoint_host || checkPeerHost(s.endpoint_host, s.endpoint_port, record[3])))
peer_name = s.description;
+ if (s.public_key == record[1])
+ peer_name_legacy = s.description;
});
+ if (!peer_name) peer_name = peer_name_legacy;
+
const peer = {
name: peer_name,
public_key: record[1],